﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace TinyCinema.UI.Pages.Promotion._Promotion
{
    /// <summary>
    /// Interaction logic for FormView.xaml
    /// </summary>
    public partial class FormView : Page
    {
        public FormView()
        {
            InitializeComponent();
            DataContext = Promotions.dataContext;
            (DataContext as Bussiness.Promotion.Promotions).Messenger.Register<Bussiness.Promotion.Message.BackConfimation>(this, ShowMessageBox1);
            (DataContext as Bussiness.Promotion.Promotions).Messenger.Register<Bussiness.Promotion.Message.BackConfimationOK>(this, (s) => MainPage.pagPromotion.FormViewModeHandle());
            (DataContext as Bussiness.Promotion.Promotions).Messenger.Register<Bussiness.Promotion.Message.DeleteFailed>(this, ShowMessageBox2);
            (DataContext as Bussiness.Promotion.Promotions).Messenger.Register<Bussiness.Promotion.Message.DeleteConfirmation>(this, ShowMessageBox3);
        }
        void ShowMessageBox1(Bussiness.Promotion.Message.BackConfimation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgExit") as String), "", MessageBoxButton.YesNo);
        }
        void ShowMessageBox2(Bussiness.Promotion.Message.DeleteFailed s)
        {
            MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgPromotionNotDelete") as String), "", MessageBoxButton.OK);
        }
        void ShowMessageBox3(Bussiness.Promotion.Message.DeleteConfirmation s)
        {
            s.Result = MessageBoxUtils.WPFMessageBox.Show((App.Current.FindResource("langMsgPromotionDelete") as String), "", MessageBoxButton.YesNo);
        }
    }
}
